package com.lifeverse.event;

import com.lifeverse.entity.NetworkHealthMetrics;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.HashMap;

/**
 * 网络健康事件
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class NetworkHealthEvent extends LifeEntityEvent {
    
    /**
     * 网络类型
     */
    private NetworkHealthMetrics.NetworkType networkType;
    
    /**
     * 网络标识符
     */
    private String networkIdentifier;
    
    /**
     * 健康评分
     */
    private BigDecimal healthScore;
    
    /**
     * 健康状态
     */
    private NetworkHealthMetrics.HealthStatus healthStatus;
    
    /**
     * 预警级别
     */
    private Integer alertLevel;
    
    /**
     * 变化类型
     */
    private HealthChangeType changeType;
    
    /**
     * 之前的健康评分
     */
    private BigDecimal previousHealthScore;
    
    public NetworkHealthEvent() {
        super();
        setEventType("NETWORK_HEALTH");
        setEventData(new HashMap<>());
    }
    
    public NetworkHealthEvent(NetworkHealthMetrics.NetworkType networkType, 
                            String networkIdentifier, 
                            BigDecimal healthScore,
                            NetworkHealthMetrics.HealthStatus healthStatus) {
        this();
        this.networkType = networkType;
        this.networkIdentifier = networkIdentifier;
        this.healthScore = healthScore;
        this.healthStatus = healthStatus;
    }
    
    /**
     * 健康变化类型枚举
     */
    public enum HealthChangeType {
        IMPROVED("改善"),
        DEGRADED("恶化"),
        STABLE("稳定"),
        CRITICAL("危险"),
        RECOVERED("恢复");
        
        private final String displayName;
        
        HealthChangeType(String displayName) {
            this.displayName = displayName;
        }
        
        public String getDisplayName() {
            return displayName;
        }
    }
}